<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>平台数据统计</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="{{asset('/layuiadmin/layui/css/layui.css')}}" media="all">
  <link rel="stylesheet" href="{{asset('/layuiadmin/style/admin.css')}}" media="all">
  <style>
    
    .userbox,.storebox{
      height:200px;
      overflow-y: auto;
      z-index: 999;
      position: absolute;
      left: 0px;
      top: 62px;
      width:298px;
      background-color:#ffffff;
      border: 1px solid #ddd;
    }
    .userbox .list,.storebox .list{
      height:38px;line-height: 38px;cursor:pointer;
      padding-left:10px;
    }
    .userbox .list:hover,.storebox .list:hover{
      background-color:#eeeeee;
    }
    .countNum{
        color:#212121;
    }
  </style>
</head>
<body>

  <div class="layui-fluid">
    <!-- 筛选------------------------------------------------------------ -->
    <div class="layui-row layui-col-space15">
      <div class="layui-col-md12" style="margin-top:0px;">
        <div class="layui-card"> 
          <div class="layui-card-header a_name">平台数据统计</div>

          <div class="layui-card-body">
            <div class="layui-btn-container" style="font-size:14px;display:flex">
              <div class="layui-form" lay-filter="component-form-group" style="display: flex">
                <div class="layui-form-item">                          
                  <div class="layui-input-block" style="margin-left:10px;">
                  <text class="yname">门店名称</text>
                    <input type="text" name="schoolname" lay-verify="schoolname" autocomplete="off" placeholder="请输入门店名称" class="layui-input inputstore">

                    <div class="storebox" style='display: none'></div>
                  </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <div class="layui-input-inline" style="width:250px;margin-left: 20px;">
                        <text class="yname">日期选择</text>
                        <input type="text" style="border-radius:5px" class="layui-input start-item-range test-item" placeholder="日期选择" lay-key="23">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">                          
                  <div class="layui-input-block" style="margin-left:10px;display:flex;margin-top:10px">
                     <button class="layui-btn" style="border-radius:5px;margin-top:15px;margin-bottom:0;" id="countsearch">搜索</button>
                     <button class="layui-btn" style="border-radius:5px;margin-top:15px;margin-bottom:0;" id="today">今日</button>
                     <button class="layui-btn" style="border-radius:5px;margin-top:15px;margin-bottom:0;" id="yesterday">昨日</button>
                     <button class="layui-btn" style="border-radius:5px;margin-top:15px;margin-bottom:0;" id="lastweek">上周</button>
                     <button class="layui-btn" style="border-radius:5px;margin-top:15px;margin-bottom:0;" id="curmonth">本月</button>
                     <button class="layui-btn" style="border-radius:5px;margin-top:15px;margin-bottom:0;" id="lastmonth">上月</button>
                  </div>
                </div>
              </div>                
            </div>  
            <div style="padding: 8px 15px;background-color: #e6f7ff;border: 1px solid #91d5ff;margin:20px 0;">
                <text>总交易额：</text><text class="countNum total_fee"></text>（<text class="countNum total_num" style="margin: 0 4px;"></text>笔）;
                <text>总退款额：</text><text class="countNum refund_fee"></text>（<text class="countNum refund_num" style="margin: 0 4px;"></text>笔）;
                <text>总佣金：</text><text class="countNum fee_column"></text>；
                <text>实收款：</text><text class="countNum receipt_amount"></text>
            </div>
            <table class="layui-hide" id="test-table-page" lay-filter="test-table-page"></table>
            <script type="text/html" id="table-content-list">
                <a class="layui-btn layui-btn-xs viewstore" lay-event="viewstore" style="border-radius:3.5px;">查看门店</a>
                <a class="layui-btn layui-btn-xs daily" lay-event="daily" style="border-radius:3.5px;margin-left:10px">每日收款</a>
                <a class="layui-btn layui-btn-xs passway" lay-event="passway" style="border-radius:3.5px;margin-left:10px">通道汇总</a>
                <a class="layui-btn layui-btn-xs paytype" lay-event="paytype" style="border-radius:3.5px;margin-left:10px">支付方式</a>
            </script>
          </div>
        </div>
      </div>
    </div>

    <!-- 显示门店 -->
    <div id="storeData" style="display: none; background-color: #fff;">
        <div style="margin: 0 20px;">
            <div style="margin: 10px 0;display:flex;color: black;font-size: 16px;text-align: center;">
                <span>总店名称：</span>
                <div class="storepidname"></div>
            </div>
            <!-- <div class="layui-form">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <div class="layui-input-inline" style="width:250px;margin-right:0;">
                            <text class="yname">日期选择</text>
                            <input type="text" style="border-radius:5px" class="layui-input store-item-range test-item" placeholder="日期选择" lay-key="23">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">                          
                    <div class="layui-input-block" style="margin-left:10px;display:flex">
                        <button class="layui-btn" style="border-radius:5px;margin-top:15px;margin-bottom:0;" id="storeSearch">搜索</button>
                    </div>
                </div>
            </div> -->
            <div style="padding: 8px 15px;background-color: #e6f7ff;border: 1px solid #91d5ff;margin:20px 0;">
                <text>总交易额：</text><text class="countNum total_fee"></text>（<text class="countNum total_num" style="margin: 0 4px;"></text>笔）；
                <text>总退款额：</text><text class="countNum refund_fee"></text>（<text class="countNum refund_num" style="margin: 0 4px;"></text>笔）；
                <text>总佣金：</text><text class="countNum fee_column"></text>；
                <text>实收款：</text><text class="countNum receipt_amount"></text>
            </div>
            <table id="storeTable" lay-filter="storeTable"></table>
            <script type="text/html" id="storeTable-list">
                <a class="layui-btn layui-btn-xs viewbranch" lay-event="viewbranch" style="border-radius:3.5px;">查看收银员</a>
            </script>
        </div>
    </div>
    <!-- 查看收银员 -->
    <div id="branchData" style="display: none; background-color: #fff;">
        <div style="margin: 0 20px;">
            <div style="margin: 10px 0;display:flex;color: black;font-size: 16px;text-align: center;">
                <span>分店名称：</span>
                <div class="storepidname"></div>
            </div>
            <div style="padding: 8px 15px;background-color: #e6f7ff;border: 1px solid #91d5ff;margin:20px 0;">
                <text>总收款：</text><text class="countNum total_fee"></text>（<text class="countNum total_num" style="margin: 0 4px;"></text>笔）；
                <text>线上退款额：</text><text class="countNum refund_fee"></text>（<text class="countNum refund_num" style="margin: 0 4px;"></text>笔）；
                <text>实收款：</text><text class="countNum receipt_amount"></text>；
                <text>手续费：</text><text class="countNum fee_amount"></text>；
                <text>结算金额：</text><text class="countNum settlement_amount"></text>
            </div>
            <div style="margin-bottom:10px;">
                <text>实收款=总收款-总退款，结算金额=总收款-退款-手续费</text>
            </div>
            <table id="branchTable" lay-filter="branchTable"></table>
        </div>
    </div>
    <!-- 每日收款 -->
    <div id="dailyData" style="display: none; background-color: #fff;">
        <div style="margin: 0 20px;">
            <div style="margin: 10px 0;display:flex;color: black;font-size: 16px;text-align: center;">
                <span>总店名称：</span>
                <div class="storepidname"></div>
            </div>
            <!-- <div class="layui-form">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <div class="layui-input-inline" style="width:250px;margin-right:0;">
                            <text class="yname">日期选择</text>
                            <input type="text" style="border-radius:5px" class="layui-input daily-item-range test-item" placeholder="日期选择" lay-key="23">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">                          
                    <div class="layui-input-block" style="margin-left:10px;display:flex">
                        <button class="layui-btn" style="border-radius:5px;margin-top:15px;margin-bottom:0;" id="dailySearch">搜索</button>
                    </div>
                </div>
            </div> -->
            <div style="padding: 8px 15px;background-color: #e6f7ff;border: 1px solid #91d5ff;margin:20px 0;">
                <text>总收款：</text><text class="countNum total_fee"></text>（<text class="countNum total_num" style="margin: 0 4px;"></text>笔）；
                <text>退款额：</text><text class="countNum refund_fee"></text>（<text class="countNum refund_num" style="margin: 0 4px;"></text>笔）；
                <text>实收款：</text><text class="countNum receipt_amount"></text>；
                <text>手续费：</text><text class="countNum fee_amount"></text>；
                <text>结算金额：</text><text class="countNum settlement_amount"></text>
            </div>
            <div style="margin-bottom:10px;">
                <text>实收款=总收款-总退款，结算金额=总收款-退款-手续费</text>
            </div>
            <table id="dailyTablePage" lay-filter="dailyTablePage"></table>
        </div>
    </div>
    <!-- 通道汇总 -->
    <div id="paywayData" style="display: none; background-color: #fff;margin:0 20px">
        <div style="margin: 10px 0;display:flex;color: black;font-size: 16px;text-align: center;">
            <span>总店名称：</span>
            <div class="storepidname"></div>
        </div>
        <!-- <div class="layui-form">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <div class="layui-input-inline" style="width:250px;margin-right:0;">
                        <text class="yname">日期选择</text>
                        <input type="text" style="border-radius:5px" class="layui-input payway-item-range test-item" placeholder="日期选择" lay-key="23">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">                          
                <div class="layui-input-block" style="margin-left:10px;display:flex">
                    <button class="layui-btn" style="border-radius:5px;margin-top:15px;margin-bottom:0;" id="paywaySearch">搜索</button>
                </div>
            </div>
        </div> -->
        <div style="padding: 8px 15px;background-color: #e6f7ff;border: 1px solid #91d5ff;margin:20px 0;">
            <text>总交易额：</text><text class="countNum total_fee"></text>（<text class="countNum total_num" style="margin: 0 4px;"></text>笔）；
            <text>总退款额：</text><text class="countNum refund_fee"></text>（<text class="countNum refund_num" style="margin: 0 4px;"></text>笔）；
            <text>总佣金：</text><text class="countNum fee_column"></text>；
            <text>实收款：</text><text class="countNum receipt_amount"></text>
        </div>
        <div style="padding: 8px 0px;margin-bottom:20px;">
            <text>实收款=总收款-总退款，结算金额=总收款-退款-手续费</text>
        </div>
        <table id="paywayTablePage" lay-filter="paywayTablePage"></table>
    </div>
    <!-- 支付方式 -->
    <div id="paytypeData" style="display: none; background-color: #fff;">
        <div style="margin: 0 20px;">
            <div style="margin: 10px 0;display:flex;color: black;font-size: 16px;text-align: center;">
                <span>总店名称：</span>
                <div class="storepidname"></div>
            </div>
            <!-- <div class="layui-form">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <div class="layui-input-inline" style="width:250px;margin-right:0;">
                            <text class="yname">日期选择</text>
                            <input type="text" style="border-radius:5px" class="layui-input paytype-item-range test-item" placeholder="日期选择" lay-key="23">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">                          
                    <div class="layui-input-block" style="margin-left:10px;display:flex">
                        <button class="layui-btn" style="border-radius:5px;margin-top:15px;margin-bottom:0;" id="paytypeSearch">搜索</button>
                    </div>
                </div>
            </div> -->
            <div style="padding: 8px 15px;background-color: #e6f7ff;border: 1px solid #91d5ff;margin:20px 0;">
                <text>总交易额：</text><text class="countNum total_fee"></text>（<text class="countNum total_num" style="margin: 0 4px;"></text>笔）；
                <text>总退款额：</text><text class="countNum refund_fee"></text>（<text class="countNum refund_num" style="margin: 0 4px;"></text>笔）；
                <text>总佣金：</text><text class="countNum fee_column"></text>；
                <text>实收款：</text><text class="countNum receipt_amount"></text>
            </div>
            <div style="margin-bottom:10px;">
                <text>实收款=总收款-总退款，结算金额=总收款-退款-手续费</text>
            </div>
            <table id="paytypeTable" lay-filter="paytypeTable"></table>
        </div>
    </div>

<input type="hidden" class="store_id">

<input type="hidden" class="start-item"><!-- 今天的开始时间 -->
<input type="hidden" class="end-item"><!-- 今天的开始时间 -->
<input type="hidden" class="store-start-item"><!-- 查看门店的开始时间 -->
<input type="hidden" class="store-end-item"><!-- 查看门店的开始时间 -->
<input type="hidden" class="payway-start-item"><!-- 通道汇总的开始时间 -->
<input type="hidden" class="payway-end-item"><!-- 通道汇总的开始时间 -->
<input type="hidden" class="daily-start-item"><!-- 每日收款的开始时间 -->
<input type="hidden" class="daily-end-item"><!-- 每日收款的开始时间 -->
<input type="hidden" class="paytype-start-item"><!-- 支付方式的开始时间 -->
<input type="hidden" class="paytype-end-item"><!-- 支付方式的开始时间 -->

<input type="hidden" class="curHdIndex"><!-- 时间选择1 今日 2昨日 3 上周 4 本月 5 上月 0自选时间范围 -->

<script src="{{asset('/layuiadmin/layui/layui.js')}}"></script>   
<script>
    var token = localStorage.getItem("Usertoken");
    var agentName = localStorage.getItem("duizhang_agentName");

    layui.config({
      base: '../../layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','form','table','laydate'], function(){
        var $ = layui.$
            ,admin = layui.admin
            ,form = layui.form
            ,table = layui.table
            ,laydate = layui.laydate;    
    

    //   未登录,跳转登录页面
    $(document).ready(function(){        
        if(token==null){
            window.location.href="{{url('/mb/login')}}"; 
        }
    })

    // 获取时间范围
    const today = getToday();
    const yesterday = getYesterday();
    const lastWeek = getLastWeek();
    const thisMonth = getThisMonth();
    const lastMonth = getLastMonth();
    
    //默认今日时间
    $('.curHdIndex').val(1);
    // $('#start-item-range').value(`${today.start} 至 ${today.end}`);
    $('.start-item').val(`${today.start}`)
    $('.end-item').val(`${today.end}`)
    
    laydate.render({
        elem: '.start-item-range'
        ,type: 'date'
        ,range:'至'
        ,max: 0 // 限制最大日期为今天
        ,value: `${today.start} 至 ${today.end}`
        ,done: function(value){
            if(value){
                $('.start-item').val(value.substring(0,10))
                $('.end-item').val(value.substring(13,value.length))
            }else{
                $('.start-item').val('')
                $('.end-item').val('')
            }
        }
    });

    // 监听输入框的变化，如果为空则清空另一个输入框的值
    $('.start-item-range').on('input', function() {
        if ($(this).val() === '') {
            $('.start-item').val('')
            $('.end-item').val('')
        }
    });
    console.log($('.start-item').val(),'starttime----')
    var tableIns = table.render({
        elem: '#test-table-page'
        // ,url: "{{url('/api/v2/Bill/User/Finance/financeMonthCount')}}"
        ,url: ""
        ,method: 'get'
        ,where:{
            token:token,
        }
        ,request:{
            pageName: 'page',
            limitName: 'pagesize'
        }
        ,page: true
        ,cellMinWidth: 150
        ,cols: [[
            {field: 'store_pid', title: '门店ID'}
            ,{field: 'store_pid_name', title: '门店名称'}
            ,{field: 'total_fee', title: '交易额'}
            ,{field: 'total_num',  title: '交易笔数'}
            ,{field: 'refund_fee',  title: '退款金额'}
            ,{field: 'refund_num',  title: '退款笔数'}
            ,{align:'center', fixed: 'right', toolbar: '#table-content-list',title: '操作'}
        ]]
        ,response: {
            statusName: 'status' //数据状态的字段名称，默认：code
            ,statusCode: 1 //成功的状态码，默认：0
            ,msgName: 'message' //状态信息的字段名称，默认：msg
            ,countName: 'total' //数据总数的字段名称，默认：count
            ,dataName: 'data' //数据列表的字段名称，默认：data
        }
        ,done: function(res, curr, count){
            $('th').css({'font-weight': 'bold', 'font-size': '15','color': 'black','background':'linear-gradient(#f2f2f2,#cfcfcf)'});	//进行表头样式设置
            // if(pageLoading){
            //     layer.close(pageLoading);
            // }
        }
    });

    var tableItemData = {}
    table.on('tool(test-table-page)', function(obj){ //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
        var e = obj.data; //获得当前行数据
        var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
        var tr = obj.tr; //获得当前行 tr 的DOM对象
        tableItemData = e;
        if(layEvent === 'viewstore'){ //查看门店
            $('#storeData .storepidname').html(e.store_pid_name);
            layer.open({
                type: 1,
                title: '查看门店',
                closeBtn: 1,
                area: '1000px',
                shadeClose: true,
                content: $('#storeData'),
                success: function(layero, index) {
                    // laydate.render({
                    //     elem: '.store-item-range'
                    //     ,type: 'date'
                    //     ,range:'至'
                    //     ,max: 0 // 限制最大日期为今天
                    //     ,done: function(value){
                    //         if(value){
                    //             $('.store-start-item').val(value.substring(0,10))
                    //             $('.store-end-item').val(value.substring(13,value.length))
                    //         }else{
                    //             $('.store-start-item').val('')
                    //             $('.store-end-item').val('')
                    //         }
                    //     }
                    // });
                    // $('#store-item-range').text(`${$('.start-item').val()} 至 ${$('.end-item').val()}`);
                    console.log($('.start-item').val(),$('.end-item').val(),'---------')
                    // console.log(`${today.start}`,'today')
                    // $('.store-start-item').val($('.start-item').val());
                    // $('.store-end-item').val($('.end-item').val());
                    let params = {
                        token:token,
                        curHdIndex:$('.curHdIndex').val(),
                        group: 'store_id',
                        store_pid: e.store_pid,
                    }
                    if($('.curHdIndex').val()==0){
                        params['startDate'] = $('.start-item').val() ? $('.start-item').val()+' 00:00:00' :'',
                        params['endDate'] = $('.end-item').val() ? $('.end-item').val() + ' 23:59:59' :''
                    }
                    getStoreCount()
                    var storeTable = table.render({
                        elem: '#storeTable'
                        ,height:480
                        ,url: "{{url('/api/v2/Bill/User/WxCount/staticStoreGroupCountList')}}"
                        ,method: 'get'
                        ,where:params
                        ,request:{
                            pageName: 'page',
                            limitName: 'pagesize'
                        }
                        ,page: true
                        ,cols: [[
                            {field: 'store_id', title: '分店ID'}
                            ,{field: 'store_id_name', title: '分店名称'}
                            ,{field: 'total_fee', title: '交易额'}
                            ,{field: 'total_num',  title: '交易笔数'}
                            ,{field: 'refund_fee',  title: '退款金额'}
                            ,{field: 'refund_num',  title: '退款笔数'}
                            ,{align:'center', fixed: 'right', toolbar: '#storeTable-list',title: '操作'}
                        ]]
                        ,response: {
                            statusName: 'status' //数据状态的字段名称，默认：code
                            ,statusCode: 1 //成功的状态码，默认：0
                            ,msgName: 'message' //状态信息的字段名称，默认：msg
                            ,countName: 'total' //数据总数的字段名称，默认：count
                            ,dataName: 'data' //数据列表的字段名称，默认：data
                        }
                        ,done: function(res, curr, count){
                            $('th').css({'font-weight': 'bold', 'font-size': '15','color': 'black','background':'linear-gradient(#f2f2f2,#cfcfcf)'});	//进行表头样式设置
                        }
                    });
                }
            });
        }else if(layEvent === 'daily'){ //每日收款
            $('#dailyData .storepidname').html(e.store_pid_name);
            layer.open({
                type: 1,
                title: '每日收款',
                closeBtn: 1,
                area: '1000px',
                shadeClose: true,
                content: $('#dailyData'),
                success: function(layero, index) {
                    // laydate.render({
                    //     elem: '.daily-item-range'
                    //     ,type: 'date'
                    //     ,range:'至'
                    //     ,max: 0 // 限制最大日期为今天
                    //     ,done: function(value){
                    //         if(value){
                    //             $('.daily-start-item').val(value.substring(0,10))
                    //             $('.daily-end-item').val(value.substring(13,value.length))
                    //         }else{
                    //             $('.daily-start-item').val('')
                    //             $('.daily-end-item').val('')
                    //         }
                    //     }
                    // });
                    // $('#daily-item-range').text(`${$('.start-item').val()} 至 ${$('.end-item').val()}`);
                    // $('.daily-start-item').val($('.start-item').val());
                    // $('.daily-end-item').val($('.end-item').val());
                    let params = {
                        token:token,
                        curHdIndex:$('.curHdIndex').val(),
                        group: 'store_id',
                        store_pid: e.store_pid,
                    }
                    if($('.curHdIndex').val()==0){
                        params['startDate'] = $('.start-item').val() ? $('.start-item').val()+' 00:00:00' :'',
                        params['endDate'] = $('.end-item').val() ? $('.end-item').val() + ' 23:59:59' :''
                    }
                    getDailyCount()
                    var dailyTable = table.render({
                        elem: '#dailyTablePage'
                        ,height:480
                        ,url: "{{url('/api/v2/Bill/User/WxCount/staticDailyCountList')}}"
                        ,method: 'get'
                        ,where:params
                        ,request:{
                            pageName: 'page',
                            limitName: 'pagesize'
                        }
                        ,page: true
                        ,cols: [[
                            {field: 'date', title: '日期',templet: function(d) {
                                console.log(d,'111111')
                                const year = d.LAY_TABLE_INDEX; // 动态获取年份键
                                return year;
                            }}
                            ,{field: 'total_fee', title: '入账金额'}
                            ,{field: 'total_num',  title: '交易笔数'}
                        ]]
                        ,response: {
                            statusName: 'status' //数据状态的字段名称，默认：code
                            ,statusCode: 1 //成功的状态码，默认：0
                            ,msgName: 'message' //状态信息的字段名称，默认：msg
                            ,countName: 'total' //数据总数的字段名称，默认：count
                            ,dataName: 'data' //数据列表的字段名称，默认：data
                        }
                        ,done: function(res, curr, count){
                            $('th').css({'font-weight': 'bold', 'font-size': '15','color': 'black','background':'linear-gradient(#f2f2f2,#cfcfcf)'});	//进行表头样式设置
                        }
                    });
                }
            });
        }else if(layEvent == 'passway') { //门店通道汇总
            $('#paywayData .storepidname').html(e.store_pid_name);
            layer.open({
                type: 1,
                title: '门店通道汇总',
                closeBtn: 1,
                area: '1000px',
                shadeClose: true,
                content: $('#paywayData'),
                success: function(layero, index) {
                    // laydate.render({
                    //     elem: '.payway-item-range'
                    //     ,type: 'date'
                    //     ,range:'至'
                    //     ,done: function(value){
                    //         if(value){
                    //             $('.payway-start-item').val(value.substring(0,10))
                    //             $('.payway-end-item').val(value.substring(13,value.length))
                    //         }else{
                    //             $('.payway-start-item').val('')
                    //             $('.payway-end-item').val('')
                    //         }
                    //     }
                    // });
                    // $('#payway-item-range').text(`${$('.start-item').val()} 至 ${$('.end-item').val()}`);
                    // $('.payway-start-item').val($('.start-item').val());
                    // $('.payway-end-item').val($('.end-item').val());
                    
                    getPaywayCount()
                    let params = {
                        token:token,
                        curHdIndex:$('.curHdIndex').val(),
                        group: 'company',
                        store_pid: e.store_pid,
                    }
                    if($('.curHdIndex').val()==0){
                        params['startDate'] = $('.start-item').val() ? $('.start-item').val()+' 00:00:00' :'',
                        params['endDate'] = $('.end-item').val() ? $('.end-item').val() + ' 23:59:59' :''
                    }
                    var paywayTable = table.render({
                        elem: '#paywayTablePage'
                        ,height:480
                        ,url: "{{url('/api/v2/Bill/User/WxCount/staticStoreGroupCountList')}}"
                        ,method: 'get'
                        ,where:params
                        ,request:{
                            pageName: 'page',
                            limitName: 'pagesize'
                        }
                        ,page: true
                        ,cols: [[
                            {field: 'company_name', title: '通道名称'}
                            ,{field: 'total_fee', title: '交易金额'}
                            ,{field: 'total_num',  title: '交易笔数'}
                            ,{field: 'refund_fee',  title: '退款金额'}
                            ,{field: 'refund_num',  title: '退款笔数'}
                            ,{field: 'fee_column',  title: '佣金'}
                        ]]
                        ,response: {
                            statusName: 'status' //数据状态的字段名称，默认：code
                            ,statusCode: 1 //成功的状态码，默认：0
                            ,msgName: 'message' //状态信息的字段名称，默认：msg
                            ,countName: 'total' //数据总数的字段名称，默认：count
                            ,dataName: 'data' //数据列表的字段名称，默认：data
                        }
                        ,done: function(res, curr, count){
                            $('th').css({'font-weight': 'bold', 'font-size': '15','color': 'black','background':'linear-gradient(#f2f2f2,#cfcfcf)'});	//进行表头样式设置
                        }
                    });
                }
            });
        }else { //paytype支付方式
            $('#paytypeData .storepidname').html(e.store_pid_name);
            layer.open({
                type: 1,
                title: '支付方式汇总',
                closeBtn: 1,
                area: '1000px',
                shadeClose: true,
                content: $('#paytypeData'),
                success: function(layero, index) {
                    getPaytypeCount()
                    // laydate.render({
                    //     elem: '.paytype-item-range'
                    //     ,type: 'date'
                    //     ,range:'至'
                    //     ,done: function(value){
                    //         if(value){
                    //             $('.paytype-start-item').val(value.substring(0,10))
                    //             $('.paytype-end-item').val(value.substring(13,value.length))
                    //         }else{
                    //             $('.paytype-start-item').val('')
                    //             $('.paytype-end-item').val('')
                    //         }
                    //     }
                    // });
                    // $('#paytype-item-range').text(`${$('.start-item').val()} 至 ${$('.end-item').val()}`);
                    // $('.paytype-start-item').val($('.start-item').val());
                    // $('.paytype-end-item').val($('.end-item').val());
                    
                }
            }); 
        }
    })

    function acount(){
        //执行重载
        var pageLoading = layer.msg('数据请求中..', {
            icon: 16
            ,shade: 0.3
            ,time: false
        });
        let starttime = $('.start-item').val();
        let endtime = $('.end-item').val();
        let startDate = '';
        let endDate = '';
        let curHdIndex = $('.curHdIndex').val();
        let Values = {
            token:token, 
            store_id:$('.store_id').val(),
            curHdIndex:curHdIndex,
            group: 'store_pid'
        }
        if(starttime && endtime && curHdIndex == 0){
            //处理开始时间和结束时间
            startDate = starttime.length<12 ? starttime + ' 00:00:00' : starttime;
            endDate = endtime.length<12 ? endtime + ' 23:59:59' : endtime;
            Values['startDate'] = startDate;
            Values['endDate'] = endDate;
        }
        tableIns.reload({
            url: "{{url('/api/v2/Bill/User/WxCount/staticStoreGroupCountList')}}",
            where: {...Values},
            page: {
                curr: 1 //重新从第 1 页开始
            },
            done:function(res, curr, count){
                layer.close(pageLoading);
            }
        });
     
    }

    function getCount (){
        //汇总统计
        let starttime = $('.start-item').val();
        let endtime = $('.end-item').val();
        let startDate = '';
        let endDate = '';
        let curHdIndex = $('.curHdIndex').val();
        let Values = {
            token:token, 
            store_id:$('.store_id').val(),
            curHdIndex:curHdIndex
        }
        if(starttime && endtime && curHdIndex == 0){
            //处理开始时间和结束时间
            startDate = starttime.length<12 ? starttime + ' 00:00:00' : starttime;
            endDate = endtime.length<12 ? endtime + ' 23:59:59' : endtime;
            Values['startDate'] = startDate;
            Values['endDate'] = endDate;
        }
        $.ajax({
            url : "{{url('/api/v2/Bill/User/WxCount/staticStoreGroupCount')}}",
            data : Values,
            type : 'get',
            dataType:'json',
            success : function(res) {
                if(res.status == 1){
                    $('.total_fee').html(res.data.total_fee || 0.00)
                    $('.total_num').html(res.data.total_num ? parseInt(res.data.total_num) : 0)
                    $('.refund_fee').html(res.data.refund_fee || 0.00)
                    $('.refund_num').html(res.data.refund_num ? parseInt(res.data.refund_num) : 0)
                    $('.fee_column').html(res.data.fee_column || 0.00)
                    $('.receipt_amount').html(res.data.receipt_amount || 0.00)
                }
            },
            error : function(data) {
                alert('查找板块报错');
            }
        });
    }

    // 选择门店
    $.ajax({
      url : "{{url('/api/user/store_lists')}}",
      data : {token:token,l:100},
      type : 'post',
      success : function(data) {
          console.log(data);
          var optionStr = "";
              for(var i=0;i<data.data.length;i++){
                  optionStr += "<option value='" + data.data[i].store_id + "'>" + data.data[i].store_name + "</option>";
              }    
              $("#schooltype").append('<option value="">选择门店</option>'+optionStr);
              layui.form.render('select');
      },
      error : function(data) {
          alert('查找板块报错');
      }
    });

    // 门店
    $(".inputstore").bind("input propertychange",function(event){
        store_name = $(this).val()
        if (store_name.length == 0) {
            $('.storebox').html('')
            $('.storebox').hide()
            $('.store_id').val('')
        } else {
          $.post("{{url('/api/user/store_lists')}}",
          {
              token:token,
              token:token,store_name:$(this).val(),l:100          

          },function(res){
              console.log(res);
              var html="";
              console.log(res.t)
              if(res.t==0){
                  $('.storebox').html('')
              }else{
                  for(var i=0;i<res.data.length;i++){
                      html+='<div class="list" data='+res.data[i].store_id+'>'+res.data[i].store_name+'</div>'
                  }
                  $(".storebox").show()
                  $('.storebox').html('')
                  $('.storebox').append(html)
              }
              
          },"json");
        }
    });
    

    $(".storebox").on("click",".list",function(){

      $('.inputstore').val($(this).html())
      $('.store_id').val($(this).attr('data'))
      $('.storebox').hide()
      
    })
    
    // 选择门店
    form.on('select(schooltype)', function(data){
      var store_id = data.value;
      $('.store_id').val(store_id);
      //执行重载
    //   acount()
    });

    // laydate.render({
    //   elem: '.start-item'
    //   ,type: 'datetime'
    //   ,min:'2024-09-13 00:00:00' //设置最小日期为2024-09-13
    //   ,done: function(value){
    //     $('.start-item').val(value)
    //     //执行重载
    //     // acount();
    //   }
    // });

    // laydate.render({
    //   elem: '.end-item'
    //   ,type: 'datetime'
    //   ,min:'2024-09-13 00:00:00' //设置最小日期为2024-09-13
    //   ,ready: function(date){
    // 		this.dateTime.hours=23;
    // 		this.dateTime.minutes=59;
    // 		this.dateTime.seconds=59;
	// 	  }
    //   ,done: function(value){
    //     $('.end-item').val(value)
    //     //执行重载
    //     // acount();
    //   }
    // });

    $('#today').click(function(){
      $('.start-item').val('')
      $('.end-item').val('');
      $('.curHdIndex').val(1);
      $('.start-item-range').val(`${today.start} 至 ${today.end}`);
      getCount();
      acount();
    })

    $('#yesterday').click(function(){
      $('.start-item').val('')
      $('.end-item').val('');
      $('.curHdIndex').val(2);
      $('.start-item-range').val(`${yesterday.start} 至 ${yesterday.end}`);
      getCount();
      acount();
    })
    $('#lastweek').click(function(){
      $('.start-item').val('')
      $('.end-item').val('');
      $('.curHdIndex').val(3);
      $('.start-item-range').val(`${lastWeek.start} 至 ${lastWeek.end}`);
      getCount();
      acount();
    })
    $('#curmonth').click(function(){
      $('.start-item').val('')
      $('.end-item').val('');
      $('.curHdIndex').val(4);
      $('.start-item-range').val(`${thisMonth.start} 至 ${thisMonth.end}`);
      getCount();
      acount();
    })
    $('#lastmonth').click(function(){
      $('.start-item').val('')
      $('.end-item').val('');
      $('.curHdIndex').val(5);
      $('.start-item-range').val(`${lastMonth.start} 至 ${lastMonth.end}`);
      getCount();
      acount();
    })

    $('#countsearch').click(function(){
        $('.curHdIndex').val(0);
        getCount();
        acount();
    })

    // 获取格式化日期（YYYY-MM-DD）
    function formatDate(date) {
        const year = date.getFullYear();
        const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始，需要+1
        const day = String(date.getDate()).padStart(2, '0');
        return `${year}-${month}-${day}`;
    }

    // 获取今日的开始时间和结束时间
    function getToday() {
        const today = new Date();
        return {
            start: formatDate(today),
            end: formatDate(today)
        };
    }

    // 获取昨日的开始时间和结束时间
    function getYesterday() {
        const yesterday = new Date();
        yesterday.setDate(yesterday.getDate() - 1);
        return {
            start: formatDate(yesterday),
            end: formatDate(yesterday)
        };
    }

    // 获取上周的开始时间和结束时间
    function getLastWeek() {
        const today = new Date();
        const dayOfWeek = today.getDay(); // 获取当前是星期几（0-6，0是周日）
        const startOfLastWeek = new Date(today);
        startOfLastWeek.setDate(today.getDate() - dayOfWeek - 7); // 上周的第一天（周日）
        const endOfLastWeek = new Date(startOfLastWeek);
        endOfLastWeek.setDate(startOfLastWeek.getDate() + 6); // 上周的最后一天（周六）
        return {
            start: formatDate(startOfLastWeek),
            end: formatDate(endOfLastWeek)
        };
    }

    // 获取本月的开始时间和结束时间
    function getThisMonth() {
        const today = new Date();
        const startOfMonth = new Date(today.getFullYear(), today.getMonth(), 1); // 本月第一天
        const endOfMonth = new Date(today.getFullYear(), today.getMonth() + 1, 0); // 本月最后一天
        return {
            start: formatDate(startOfMonth),
            end: formatDate(endOfMonth)
        };
    }

    // 获取上月的开始时间和结束时间
    function getLastMonth() {
        const today = new Date();
        const startOfLastMonth = new Date(today.getFullYear(), today.getMonth() - 1, 1); // 上月第一天
        const endOfLastMonth = new Date(today.getFullYear(), today.getMonth(), 0); // 上月最后一天
        return {
            start: formatDate(startOfLastMonth),
            end: formatDate(endOfLastMonth)
        };
    }

    //查看门店数据-搜索
    $('#storeSearch').click(function(){
        let starttime = $('.store-start-item').val();
        let endtime = $('.store-end-item').val();
        let startDate = '';
        let endDate = '';
        let Values = {
            token:token, 
            curHdIndex:0,
            group: 'store_id',
            store_pid:tableItemData.store_pid
        }
        if(starttime && endtime){
            //处理开始时间和结束时间
            startDate = starttime.length<12 ? starttime + ' 00:00:00' : starttime;
            endDate = endtime.length<12 ? endtime + ' 23:59:59' : endtime;
            Values['startDate'] = startDate;
            Values['endDate'] = endDate;
        }
        getStoreCount()
        storeTable.reload({
            url: "{{url('/api/v2/Bill/User/WxCount/staticStoreGroupCountList')}}",
            where: {...Values},
            page: {
                curr: 1 //重新从第 1 页开始
            },
            done:function(res, curr, count){
                layer.close(pageLoading);
            }
        });
    })
    
    //查看门店交易统计
    function getStoreCount(){
        let starttime = $('.start-item').val();
        let endtime = $('.end-item').val();
        let startDate = '';
        let endDate = '';
        let Values = {
            token:token, 
            curHdIndex:$('.curHdIndex').val(),
            group: 'store_id',
            store_pid:tableItemData.store_pid
        }
        if(starttime && endtime && $('.curHdIndex').val()==0){
            //处理开始时间和结束时间
            startDate = starttime.length<12 ? starttime + ' 00:00:00' : starttime;
            endDate = endtime.length<12 ? endtime + ' 23:59:59' : endtime;
            Values['startDate'] = startDate;
            Values['endDate'] = endDate;
        }
        $.ajax({
            url : "{{url('/api/v2/Bill/User/WxCount/staticStoreGroupCount')}}",
            data : Values,
            type : 'get',
            dataType:'json',
            success : function(res) {
                if(res.status == 1){
                    $('#storeData .total_fee').html(res.data.total_fee || 0.00)
                    $('#storeData .total_num').html(res.data.total_num ? parseInt(res.data.total_num) : 0)
                    $('#storeData .refund_fee').html(res.data.refund_fee || 0.00)
                    $('#storeData .refund_num').html(res.data.refund_num ? parseInt(res.data.refund_num) : 0)
                    $('#storeData .fee_column').html(res.data.fee_column || 0.00)
                    $('#storeData .receipt_amount').html(res.data.receipt_amount || 0.00)
                }
            },
            error : function(data) {
                alert('查找板块报错');
            }
        });

    }

    //分店列表操作-查看收银员
    table.on('tool(storeTable)', function(obj){ //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
        var e = obj.data; //获得当前行数据
        var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
        var tr = obj.tr; //获得当前行 tr 的DOM对象
        if(layEvent === 'viewbranch'){ //查看收银员
            $('#branchData .storepidname').html(e.store_id_name);
            layer.open({
                type: 1,
                title: '查看收银员',
                closeBtn: 1,
                area: '800px',
                shadeClose: true,
                content: $('#branchData'),
                success: function(layero, index) {
                    let params = {
                        token:token,
                        curHdIndex:$('.curHdIndex').val(),
                        group: 'merchant_id',
                        store_id:e.store_id,
                        store_pid: e.store_pid,
                        startDate:$('.start-item').val() ? $('.start-item').val()+' 00:00:00' :'',
                        endDate:$('.end-item').val() ? $('.end-item').val()+' 23:59:59' :''
                    }
                    var branchIns = table.render({
                        elem: '#branchTable'
                        ,height:480
                        ,url: "{{url('/api/v2/Bill/User/WxCount/staticStoreGroupCountList')}}"
                        ,method: 'get'
                        ,where:params
                        ,request:{
                            pageName: 'page',
                            limitName: 'pagesize'
                        }
                        ,page: true
                        ,cols: [[
                            {field: 'cashier_name', title: '收银员'}
                            ,{field: 'store_id_name', title: '分店名称'}
                            ,{field: 'total_fee', title: '交易额'}
                            ,{field: 'total_num',  title: '交易笔数'}
                            ,{field: 'refund_fee',  title: '退款金额'}
                            ,{field: 'refund_num',  title: '退款笔数'}
                        ]]
                        ,response: {
                            statusName: 'status' //数据状态的字段名称，默认：code
                            ,statusCode: 1 //成功的状态码，默认：0
                            ,msgName: 'message' //状态信息的字段名称，默认：msg
                            ,countName: 'total' //数据总数的字段名称，默认：count
                            ,dataName: 'data' //数据列表的字段名称，默认：data
                        }
                        ,done: function(res, curr, count){
                            $('th').css({'font-weight': 'bold', 'font-size': '15','color': 'black','background':'linear-gradient(#f2f2f2,#cfcfcf)'});	//进行表头样式设置
                        }
                    });
                    //查看收银员统计数据
                    $.ajax({
                        url : "{{url('/api/v2/Bill/User/WxCount/staticStoreGroupCount')}}",
                        data : params,
                        type : 'get',
                        dataType:'json',
                        success : function(res) {
                            if(res.status == 1){
                                $('#branchData .total_fee').html(res.data.total_fee || 0.00)
                                $('#branchData .total_num').html(res.data.total_num ? parseInt(res.data.total_num) : 0)
                                $('#branchData .refund_fee').html(res.data.refund_fee || 0.00)
                                $('#branchData .refund_num').html(res.data.refund_num ? parseInt(res.data.refund_num) : 0)
                                $('#branchData .fee_column').html(res.data.fee_column || 0.00)
                                $('#branchData .receipt_amount').html(res.data.receipt_amount || 0.00)
                                $('#branchData .settlement_amount').html(res.data.settlement_amount || 0.00)
                            }
                        },
                        error : function(data) {
                            alert('查找板块报错');
                        }
                    });
                }
            });
        }
    })

    //查看每日收款统计数据
    function getDailyCount(){
        let starttime = $('.start-item').val();
        let endtime = $('.end-item').val();
        let startDate = '';
        let endDate = '';
        let Values = {
            token:token, 
            curHdIndex:$('.curHdIndex').val(),
            store_pid:tableItemData.store_pid
        }
        if(starttime && endtime && $('.curHdIndex').val()==0){
            //处理开始时间和结束时间
            startDate = starttime.length<12 ? starttime + ' 00:00:00' : starttime;
            endDate = endtime.length<12 ? endtime + ' 23:59:59' : endtime;
            Values['startDate'] = startDate;
            Values['endDate'] = endDate;
        }
        $.ajax({
            url : "{{url('/api/v2/Bill/User/WxCount/staticDailyCount')}}",
            data : Values,
            type : 'get',
            dataType:'json',
            success : function(res) {
                if(res.status == 1){
                    $('#dailyData .total_fee').html(res.data.total_fee || 0.00)
                    $('#dailyData .total_num').html(res.data.total_num ? parseInt(res.data.total_num) : 0)
                    $('#dailyData .refund_fee').html(res.data.refund_fee || 0.00)
                    $('#dailyData .refund_num').html(res.data.refund_num ? parseInt(res.data.refund_num) : 0)
                    $('#dailyData .fee_amount').html(res.data.fee_amount || 0.00)
                    $('#dailyData .receipt_amount').html(res.data.receipt_amount || 0.00)
                    $('#dailyData .settlement_amount').html(res.data.settlement_amount || 0.00)
                }
            },
            error : function(data) {
                alert('查找板块报错');
            }
        });
    }
    //查看每日收款-搜索
    $('#dailySearch').click(function(){
        let starttime = $('.daily-start-item').val();
        let endtime = $('.daily-end-item').val();
        let startDate = '';
        let endDate = '';
        let Values = {
            token:token, 
            curHdIndex:$('.curHdIndex').val(),
            group: 'store_id',
            store_pid:tableItemData.store_pid
        }
        // let params = {
        //     token:token,
        //     curHdIndex:0,
        //     store_pid: e.store_pid,
        // }
        if(starttime && endtime && $('.curHdIndex').val()==0){
            //处理开始时间和结束时间
            startDate = starttime.length<12 ? starttime + ' 00:00:00' : starttime;
            endDate = endtime.length<12 ? endtime + ' 23:59:59' : endtime;
            Values['startDate'] = startDate;
            Values['endDate'] = endDate;
        }
        getDailyCount()
        dailyTable.reload({
            url: "{{url('/api/v2/Bill/User/WxCount/staticDailyCountList')}}",
            where: Values,
            page: {
                curr: 1 //重新从第 1 页开始
            },
            done:function(res, curr, count){
                layer.close(pageLoading);
            }
        });
    })

    //通道汇总交易统计
    function getPaywayCount(){
        let starttime = $('.start-item').val();
        let endtime = $('.end-item').val();
        let startDate = '';
        let endDate = '';
        let Values = {
            token:token, 
            curHdIndex:$('.curHdIndex').val(),
            store_pid:tableItemData.store_pid
        }
        if(starttime && endtime && $('.curHdIndex').val()==0){
            //处理开始时间和结束时间
            startDate = starttime.length<12 ? starttime + ' 00:00:00' : starttime;
            endDate = endtime.length<12 ? endtime + ' 23:59:59' : endtime;
            Values['startDate'] = startDate;
            Values['endDate'] = endDate;
        }
        $.ajax({
            url : "{{url('/api/v2/Bill/User/WxCount/staticStoreGroupCount')}}",
            data : Values,
            type : 'get',
            dataType:'json',
            success : function(res) {
                if(res.status == 1){
                    $('#paywayData .total_fee').html(res.data.total_fee || 0.00)
                    $('#paywayData .total_num').html(res.data.total_num ? parseInt(res.data.total_num) : 0)
                    $('#paywayData .refund_fee').html(res.data.refund_fee || 0.00)
                    $('#paywayData .refund_num').html(res.data.refund_num ? parseInt(res.data.refund_num) : 0)
                    $('#paywayData .fee_column').html(res.data.fee_column || 0.00)
                    $('#paywayData .receipt_amount').html(res.data.receipt_amount || 0.00)
                    $('#paywayData .settlement_amount').html(res.data.settlement_amount || 0.00)
                }
            },
            error : function(data) {
                alert('查找板块报错');
            }
        });
    }
    //通道汇总-搜索
    $('#paywaySearch').click(function(){
        let starttime = $('.payway-start-item').val();
        let endtime = $('.payway-end-item').val();
        let startDate = '';
        let endDate = '';
        let Values = {
            token:token, 
            curHdIndex:0,
            group: 'company',
            store_pid:tableItemData.store_pid
        }
        if(starttime && endtime){
            //处理开始时间和结束时间
            startDate = starttime.length<12 ? starttime + ' 00:00:00' : starttime;
            endDate = endtime.length<12 ? endtime + ' 23:59:59' : endtime;
            Values['startDate'] = startDate;
            Values['endDate'] = endDate;
        }
        getPaywayCount()
        paywayTable.reload({
            url: "{{url('/api/v2/Bill/User/WxCount/staticStoreGroupCountList')}}",
            where: Values,
            page: {
                curr: 1 //重新从第 1 页开始
            },
            done:function(res, curr, count){
                layer.close(pageLoading);
            }
        });
    })

    // 支付方式汇总
    function getPaytypeCount(type){
        let starttime = $('.start-item').val();
        let endtime = $('.end-item').val();
        let startDate = '';
        let endDate = '';
        let Values = {
            token:token, 
            curHdIndex:$('.curHdIndex').val(),
            store_pid:tableItemData.store_pid
        }
        if(starttime && endtime && $('.curHdIndex').val()==0){
            //处理开始时间和结束时间
            startDate = starttime.length<12 ? starttime + ' 00:00:00' : starttime;
            endDate = endtime.length<12 ? endtime + ' 23:59:59' : endtime;
            Values['startDate'] = startDate;
            Values['endDate'] = endDate;
        }
        $.ajax({
            url : "{{url('/api/v2/Bill/User/WxCount/payTypeCount')}}",
            data : Values,
            type : 'get',
            dataType:'json',
            success : function(res) {
                if(res.status == 1){
                    $('#paytypeData .total_fee').html(res.data.total_fee || 0.00)
                    $('#paytypeData .total_num').html(res.data.total_num ? parseInt(res.data.total_num) : 0)
                    $('#paytypeData .refund_fee').html(res.data.refund_fee || 0.00)
                    $('#paytypeData .refund_num').html(res.data.refund_num ? parseInt(res.data.refund_num) : 0)
                    $('#paytypeData .fee_column').html(res.data.fee_column || 0.00)
                    $('#paytypeData .receipt_amount').html(res.data.receipt_amount || 0.00)
                    $('#paytypeData .settlement_amount').html(res.data.settlement_amount || 0.00)

                    let datalist = [];
                    let dataInfo = res.data || {};
                    if(Object.keys(dataInfo).length>0){
                        datalist = [
                            {
                                paytype_name:'微信支付',
                                total_fee:dataInfo.total_fee_wx || 0,
                                total_num:dataInfo.total_num_wx ? parseInt(dataInfo.total_num_wx) : 0,
                                refund_fee:dataInfo.refund_fee_wx || 0,
                            },
                            {
                                paytype_name:'支付宝',
                                total_fee:dataInfo.total_fee_zfb || 0,
                                total_num:dataInfo.total_num_zfb ? parseInt(dataInfo.total_num_zfb) : 0,
                                refund_fee:dataInfo.refund_fee_zfb || 0
                            },
                            {
                                paytype_name:'云闪付',
                                total_fee:dataInfo.total_fee_ysf || 0,
                                total_num:dataInfo.total_num_ysf ? parseInt(dataInfo.total_num_ysf) : 0,
                                refund_fee:dataInfo.refund_fee_ysf || 0
                            },
                            {
                                paytype_name:'翼支付',
                                total_fee:dataInfo.total_fee_yzf || 0,
                                total_num:dataInfo.total_num_yzf ? parseInt(dataInfo.total_num_yzf) : 0,
                                refund_fee:dataInfo.refund_fee_yzf || 0
                            },
                            {
                                paytype_name:'刷卡支付',
                                total_fee:dataInfo.total_fee_sk || 0,
                                total_num:dataInfo.total_num_sk ? parseInt(dataInfo.total_num_sk) : 0,
                                refund_fee:dataInfo.refund_fee_sk || 0
                            }
                        ]
                    }
                    table.render({
                        elem: '#paytypeTable'
                        ,height:480
                        ,page: false
                        ,cols: [[
                            {field: 'paytype_name', title: '支付方式'}
                            ,{field: 'total_fee', title: '交易金额'}
                            ,{field: 'total_num',  title: '交易笔数'}
                            ,{field: 'refund_fee',  title: '退款金额'}
                        ]]
                        ,data:datalist
                        ,done: function(res, curr, count){
                            $('th').css({'font-weight': 'bold', 'font-size': '15','color': 'black','background':'linear-gradient(#f2f2f2,#cfcfcf)'});	//进行表头样式设置
                        }
                    });
                }
            },
            error : function(data) {
                alert('查找板块报错');
            }
        });
    }
    //支付方式-搜索
    $('#paytypeSearch').click(function(){
        
        getPaytypeCount()
    })

    });

  </script>

</body>
</html>